package gui;

import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;

/**
 * A class to create buttons in a JTable
 * @author Sarah Wegner & Gabrielle DuBois
 */
public class ButtonRenderer extends JButton implements TableCellRenderer{

      public ButtonRenderer() {
            setOpaque(true);
      }//constructor

      public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {

            if (isSelected) {
              setForeground(table.getSelectionForeground());
              setBackground(table.getSelectionBackground());
            }//if
            else {
              setForeground(table.getForeground());
              setBackground(UIManager.getColor("Button.background"));
            }//else

            setText((value == null) ? "" : value.toString());
            return this;
      }//getTableCellRendererComponent
}//ButtonRederer Class
